<?php
class personnelAction extends SaleAction
{
    public function resume()
    {
        $filetable="personnelfile";

        $page = I("get.p");

        $query_userName = I("get.query_userName") ;
        if($query_userName=="0")
            $query_userName='';
        if (!mb_check_encoding($query_userName, 'utf-8')){
            $query_userName = iconv('gb2312', 'utf-8', $query_userName);
        }
        $this->query_userName=$query_userName;

        $condition["name"]=  array("exp", "like '%$query_userName%'");
        $condition["status"]="0";

        $data = $this->getPageData($filetable, $page, $condition);

        //dump($data["list"]);

        $this->assign('reaume_list', $data["list"]); // 数据列表变量赋值
        $this->assign('page_method', $data['pageshow']); //分页列表变量赋值
        $this->display(); // 输出模板
    }

    public function entryfiles()
    {
        $filetable="personnelfile";
        $page = I("get.p");

        $query_userName = I("get.query_userName") ;
        if($query_userName=="0")
            $query_userName='';
        if (!mb_check_encoding($query_userName, 'utf-8')){
            $query_userName = iconv('gb2312', 'utf-8', $query_userName);
        }
        $this->query_userName=$query_userName;

        $condition["name"]=  array("exp", "like '%$query_userName%'");
        $condition["status"]="1";

        $data = $this->getPageData($filetable, $page, $condition);

        //dump($data["list"]);

        $this->assign('reaume_list', $data["list"]); // 数据列表变量赋值
        $this->assign('page_method', $data['pageshow']); //分页列表变量赋值
        $this->display(); // 输出模板
    }

    public function quitfiles()
    {
        $filetable="personnelfile";
        $page = I("get.p");

        $query_userName = I("get.query_userName") ;
        if($query_userName=="0")
            $query_userName='';
        if (!mb_check_encoding($query_userName, 'utf-8')){
            $query_userName = iconv('gb2312', 'utf-8', $query_userName);
        }
        $this->query_userName=$query_userName;

        $condition["name"]=  array("exp", "like '%$query_userName%'");
        $condition["status"]="2";

        $data = $this->getPageData($filetable, $page, $condition);

        //dump($data["list"]);

        $this->assign('reaume_list', $data["list"]); // 数据列表变量赋值
        $this->assign('page_method', $data['pageshow']); //分页列表变量赋值
        $this->display(); // 输出模板
    }

    public function addresume()
    {
        $id=$_GET['id'];
        $page=$_GET['page'];

        $this->page=$page;
        if($id!='')   //如果编辑的话
        {
            $this->action="edit";
            $filedata=M("personnelfile");
            $data_Item=$filedata->where("id=$id")->find();

            $this->resume=$data_Item;
        }
        else
        {
            $this->action="add";
        }
        $this->display();
    }

    public function saveresume()
    {
        $table = D("personnelfile"); // 实例化模型类
        $data = $table->create();
        if(!$data)
        {
            $this->error($table->getError());
        }

        $action=I('post.action');
        $page=I('post.page');
        if($action=="add")
        {
            if (!$table->add($data))
            {
                $this->error("提交失败");
            }
        }
        else
        {
            $result=$table->save($data);
            if(false===$result)
            {
                $this->error("提交失败");
            }
        }
        $this->assign("waitSecond", 1);
        $this->assign("jumpUrl", U("personnel/$page"));
        $this->success("保存成功");
    }

    public function delresume()
    {
        $personnelfile = M("personnelfile");
        if (!$personnelfile->delete($_GET['id']))
        {
            $this->error("删除失败");
        } else
        {
            $this->success("删除成功");
        }
    }

    public function entry()
    {
        $id=$_GET['id'];
        $table = M("personnelfile");
        $data = array('status' => "1","entrydate"=>date("Y-m-d H:i:s"));

        $table->where("id=$id")->save($data); // 根据条件保存修改的数据
        $this->success('操作成功');
    }

    public function quit()
    {
        $id=$_GET['id'];
        $table = M("personnelfile");
        $data = array('status' => "2","quitdate"=>date("Y-m-d H:i:s"));

        $table->where("id=$id")->save($data); // 根据条件保存修改的数据
        $this->success('操作成功');
    }


}
?>